
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class SimpleAnagram {
	public  boolean Check(String str_1, String str_2) {
		String pureStr_1 = str_1.replace(" ", "");
		String pureStr_2 = str_2.replace(" ", "");
		
		int len = pureStr_1.length(); 
		
		if(len != pureStr_2.length()) {
			return false;
		}
		
                pureStr_1 = pureStr_1.toLowerCase();
                pureStr_2 = pureStr_2.toLowerCase();
                
		//arrays are automatically initialized to zero
		int[] mask_1 = new int[len];
		int[] mask_2 = new int[len];
		boolean noFind = true;
		
		for (int i = 0; i < len; i++) {
			if (mask_1[i] == 0) {
				for (int j = 0; j < len; j++) {
					if ((mask_2[j] == 0) && 
					    (pureStr_2.charAt(j) == pureStr_1.charAt(i))) {
							mask_1[i] = 1;
							mask_2[j] = 1;
							noFind = false;
							break;
						}
				}
			
				if(noFind) {
					return false;
				}
			}
		}
		
		return true; 
	}
	
	public String InputString(String msg) {
		while(true) {
			try {
				System.out.println(msg);
				BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
				return in.readLine();
					
			}catch(Exception ex) {
				System.out.println("Try another!!!");
			}
		}
	}
	
	public static void main(String[] args) {
		SimpleAnagram mySimpleAnagram = new SimpleAnagram();
		
		String inputString_1 = mySimpleAnagram.InputString("Inpur first string please:");
		String inputString_2 = mySimpleAnagram.InputString("Inpur second string please:");
		
		if (mySimpleAnagram.Check(inputString_1, inputString_2) == true) {
				System.out.println("Your strings make an Anagram");
				return;
		}
		System.out.println("Your strings don't make an Anagram");
	}  
}